package it.traveldreamWeb.shared;

import it.traveldream.dto.TransportMeanDTO;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

public class MeanDataModel extends ListDataModel<TransportMeanDTO> implements SelectableDataModel<TransportMeanDTO>{
	public MeanDataModel() {  
    }  
  
    public MeanDataModel(List<TransportMeanDTO> data) {  
        super(data);  
    }

	@Override
	public TransportMeanDTO getRowData(String rowKey) {
		
		@SuppressWarnings("unchecked")
		List<TransportMeanDTO> means = (List<TransportMeanDTO>) this.getWrappedData();
		
		for (TransportMeanDTO m : means){
			if (m.getProductId().equals(Long.decode(rowKey)))
				return m;
		}
		return null;
	}

	@Override
	public Object getRowKey(TransportMeanDTO m) {
		return m.getProductId();
	} 
}